package com.cqu.lpss.controller;

import com.cqu.lpss.pojo.*;
import com.cqu.lpss.service.impl.FirstScoringImpl;
import com.cqu.lpss.service.impl.SecondScoringImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/firstscoring")
public class FirstScoringController {
    @Autowired
    FirstScoringImpl firstScoringImpl;
    @Autowired
    SecondScoringImpl secondScoringImpl;
    @PostMapping("/isEmpty")
    public Result isEmpty(){
        int empty = firstScoringImpl.isEmpty();
        return Result.success(empty);
    }
    @PostMapping("/scoreIsNull")
    public Result scoreIsNull(){
        return Result.success(firstScoringImpl.scoreisNull());
    }
    @PostMapping("/distributionfirst")
    public Result distributionfirst(){
        firstScoringImpl.distribution(0,4);
        int num = firstScoringImpl.isEmpty();
        if(num!=0){
            return Result.success();
        }
        else {
            return Result.erro("分配失败联系管理员");
        }
    }
    @PostMapping("/distributionfinal")
    public Result distributionfinal(){
        firstScoringImpl.distribution(1,3);
        int num = secondScoringImpl.EmptyNum();
        if(num!=0){
            return Result.success();
        }
        else {
            return Result.erro("分配失败联系管理员");
        }
    }
    @PostMapping("/prjsScoreByProId")
    public Result prjsScoreByProId(@RequestParam Integer proIndex){
        List<Projects> projects = firstScoringImpl.prjScoByProId(proIndex);
        return Result.success(projects);
    }
    @PostMapping("/recordDetailScores")
    public Result recordDetailScores(@RequestBody List<Scoredetail1> scoredetail1s){
        int i = firstScoringImpl.modifyScore(scoredetail1s);
        if(i!=0){
            return Result.success();
        }
        return Result.erro("未知错误");
    }
    /**
    * @Description:用于初审时，监测每个专家还有多少作品没有评审完
    * @Param:[]
    * @Return: com.cqu.lpss.pojo.Result
    * @Date: 2024/5/8
    * @Author:liuyawen
    */

    @PostMapping("/proUnscoreNum")
    public Result proUnscoreNum(){
        List<ChartsData> professorUnscoreNums = firstScoringImpl.proUnscoreNum();
        return Result.success(professorUnscoreNums);
    }
}
